﻿using System;

namespace MathService
{
    /// <summary>Константы</summary>
    public static partial class Consts
    {
        /// <summary>% = 0.01</summary>
        public const double Percent = 0.01;

        /// <summary>e = 2.7182818284590452353602874713527</summary>
        public const double e = 2.7182818284590452353602874713527;
        /// <summary>π/2</summary>
        public const double pi05 = .5 * pi;
        /// <summary>π = 3.1415926535897932384626433832795</summary>
        public const double pi = 3.1415926535897932384626433832795;
        /// <summary>2·π</summary>
        public const double pi2 = 2 * pi;

        /// <summary>√2 = 1.4142135623730950488016887242097</summary>
        public const double sqrt_2 = 1.4142135623730950488016887242097;
        /// <summary>1 / √2 = 0.707...</summary>
        public const double sqrt_2_inv = 1 / sqrt_2;

        /// <summary>Геометрические константы</summary>
        public static class Geometry
        {
            /// <summary>Константа преобразования радиан в градусы = 180/π</summary>
            public const double ToDeg = 180 / pi;
            /// <summary>Константа преобразования градусов в радианы = π/180</summary>
            public const double ToRad = pi / 180;
            /// <summary>Константа π = 3.1415926535897932384626433832</summary>
            public const double Pi = Math.PI;

            public static double ConvertToDeg(double RadValue) { return RadValue * ToDeg; }

            public static double ConvertToRad(double DegValue) { return DegValue * ToRad; }
        }

        /// <summary>Скорость света 300`000`000 м/с = 3e8 м/с</summary>
        public const double SpeedOfLigth = 3e8;
        /// <summary>Скорость света в вакууме 299`792`458 м/с</summary>
        public const double SpeedOfLightInVacuum = 299792458;

        /// <summary>Гравитационная постоянная 6.67428(67)×10^−11 m^3·кг^−1·с^−2</summary>
        public const double GravitationConstant = 6.6742867676767676767676767E-11;

        /// <summary>Постоянная Планка 6.626 068 96(33) ×10^−34 Жд·с</summary>
        public const double PlanckConstant = 6.62606896333333333333333333E-34;

        /// <summary>Приведённая постоянная Планка 1.054 571 628(53) ×10^−34 Жд·с</summary>
        public const double PlanckConstant_Reduced = PlanckConstant / (2 * pi);

        public static class ElectroDynamic
        {

            /// <summary>Электрическая постоянная 1/(Mu0 · c^2) = 8,854187817620… ×10^−12 Ф·м^−1</summary>
            public const double Epsilon0 = 1 / (Mu0 * SpeedOfLightInVacuum * SpeedOfLightInVacuum);

            /// <summary>Магнитная постоянная 4·π ×10^-7 = 1.25663706E-6 Гн/м</summary>
            public const double Mu0 = 4 * pi * 1E-7;


            public static double ToWaveLength(double Frequancy)
            {
                return SpeedOfLigth / Frequancy;
            }

            public static double ToWaveLength(double Frequance, double Epsilon)
            {
                return SpeedOfLigth / Frequance / Math.Sqrt(Epsilon);
            }

            public static double ToWaveLength(double Frequance, double Epsilon, double Mu)
            {
                return SpeedOfLigth / Frequance / Math.Sqrt(Epsilon / Mu);
            }

            public static double ToFrequance(double WaveLength)
            {
                return SpeedOfLigth / WaveLength;
            }

            public static double ToFrequance(double WaveLength, double Epsilon)
            {
                return SpeedOfLigth / WaveLength / Math.Sqrt(Epsilon);
            }

            public static double ToFrequance(double WaveLength, double Epsilon, double Mu)
            {
                return SpeedOfLigth / WaveLength / Math.Sqrt(Epsilon / Mu);
            }
        }

        public const int BigPrime_int = 0x3ffeffff;
        public const long BigPrime_long = 0x3fffffefffffff;

        public static class DataLength
        {
            public static class Bytes
            {
                public const int B = 1;
                public const int kB = 0x400 * B;
                public const int MB = 0x400 * kB;
                public const int GB = 0x400 * MB;
                public const long TB = 1024L * GB;
            }
        }
    }
}
